//
//  SchoolManager.m
//  JSON的序列化
//
//  Created by 伍银荣 on 2021/9/4.
//  Copyright © 2021 com.WYR. All rights reserved.
//

#import "SchoolManager.h"
#import "Student.h"
#import "Teacher.h"

@implementation SchoolManager

-(instancetype)initWithDict:(NSDictionary *)dict {
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
        //self.studentID = dict[@"studentID"];
        //学生类
        NSMutableArray *stuMarr = [NSMutableArray array];
        for (NSDictionary *dict_stu in self.student) {
            Student *stuModel = [Student studentWithDict:dict_stu];
            [stuMarr addObject:stuModel];
        }
        self.student = stuMarr.copy;
        
        //教师类
        NSMutableArray *teaMarr = [NSMutableArray array];
        for (NSDictionary *dict_tea in self.teacher) {
            Teacher *teaModel = [Teacher teacherWithDict:dict_tea];
            [teaMarr addObject:teaModel];
        }
        self.teacher = teaMarr.copy;
    }
    return self;
}

+(instancetype)schoolManagerWithDict:(NSDictionary *)dict {
    return [[self alloc]initWithDict:dict];
}


@end



